home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-07-15 | 2.2 KB | 69 lines | [TEXT/KAHL] |
-
- /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- old-style bitmap utility routines for allocating, de-allocating, and masking.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-
- void FreeBitMap(BitMap *Bits)
- /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Dumps a BitMap created by NewBitMap below.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- {
- DisposPtr(Bits->baseAddr);
- Bits->baseAddr=NIL;
- SetRect(&Bits->bounds,0,0,0,0);
- Bits->rowBytes=0;
- }
-
- void CalcOffScreen(register Rect *frame,register long *needed, register short *rows)
- /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Calculates how much memory and rowbytes a bitmap of the size frame would require.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- {
- *rows=((((frame->right) - (frame->left)) + 15)/16) *2;
- *needed=(((long)(*rows)) * (long)((frame->bottom) - (frame->top)));
- }
-
- void NewBitMap(Rect *frame,BitMap *theMap)
- /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Creates a new empty bitmap.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- {
- Size size;
- int rbytes;
-
- CalcOffScreen(frame,&size,&rbytes);
-
- theMap->rowBytes=rbytes;
- theMap->bounds=*frame;
- theMap->baseAddr=NewPtrClear(size);
- }
-
-
- void NewMaskedBitMap(BitMap *srcBits, BitMap *maskBits, Rect *srcRect)
- /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Pass a pointer to an existing bitmap, and this creates a bitmap that is an
- equivelent mask.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- {
- short rowbytes,height,words;
- long needed;
-
- NewBitMap(srcRect,maskBits);
-
- if(MemErr)
- {
- maskBits->baseAddr=NIL;
- SetRect(&maskBits->bounds,0,0,0,0);
- maskBits->rowBytes=0;
- }
- else /* memory was allocated for Mask BitMap ok */
- {
- CalcOffScreen(srcRect,&needed,&rowbytes);
- words=rowbytes/2;
- height=srcRect->bottom - srcRect->top;
- CalcMask(srcBits->baseAddr,maskBits->baseAddr,rowbytes,rowbytes,height,words);
- }
- }
-